<?php
// 直接使用PDO连接MySQL
$host = '127.0.0.1';
$port = 3306;
$database = 'qiandao';
$username = 'root';
$password = 'root';

try {
    $pdo = new PDO("mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    echo "=== 检查系统菜单 ===\n\n";

    $stmt = $pdo->query("SELECT * FROM system_menu WHERE status = 1 ORDER BY sort DESC, id ASC");
    $menus = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo "总共有 " . count($menus) . " 个菜单\n\n";

    foreach ($menus as $menu) {
        $indent = str_repeat('  ', $menu['spt'] - 1);
        echo $indent . $menu['title'] . " (id:{$menu['id']}, pid:{$menu['pid']})\n";
    }

    echo "\n=== 检查admin用户权限 ===\n\n";

    $stmt = $pdo->prepare("SELECT * FROM system_user WHERE username = ?");
    $stmt->execute(['admin']);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($user) {
        echo "用户ID: {$user['id']}\n";
        echo "用户名: {$user['username']}\n";
        echo "授权: {$user['authorize']}\n";
        echo "状态: {$user['status']}\n";
    } else {
        echo "未找到admin用户\n";
    }

} catch (PDOException $e) {
    echo "错误: " . $e->getMessage() . "\n";
}

